[#ftl]
[@define "agile.form.CheckBox" "agile.form._FormValueWidget" ]
	category:"CheckBox Component"
	,widgetName:"CheckBox"
	,styleConstraints:agile.delegate(agile.form._FormValueWidget.prototype.styleConstraints,{
		width: {ignore:function(widget,sourceType){ return sourceType !="agile"}}
		,height: {ignore:function(widget,sourceType){ return sourceType !="agile"}}
	})
	,attributes:agile.delegate(agile.form._FormValueWidget.prototype.attributes,{		
	   value:lang.mixin({},agile.TextMetadata,{
		   label:"i18n_value"//the value to submit to server when this check-box is checked
		   ,onValueChange:function(/*widget*/widget,/*String*/name,/*Object*/value){	
				widget.delegate.reset1(name,value);	
				widget.metadata(this.metadataCategory+"."+name,value);			
			}
	    })
	    ,checked:lang.mixin({},agile.BooleanMetadata,{
		   label:"i18n_checked"
		   ,onValueChange:function(/*widget*/widget,/*String*/name,/*Object*/value){
				widget.delegate.set(name,value);		
				widget.metadata(this.metadataCategory+"."+name,value);				
			}
	    })
	    ,readOnly: {
	    	onValueChange:function(/*widget*/widget,/*String*/name,/*Object*/value){											
				//widget.delegate.set(name,value);
				widget.metadata(this.metadataCategory+"."+name,value);
			}
	    }	
		,disabled: {
	    	onValueChange:function(/*widget*/widget,/*String*/name,/*Object*/value){											
				//widget.delegate.set(name,value);
				widget.metadata(this.metadataCategory+"."+name,value);
			}
	    }
	})
	,_getDelegatePrototype:function(){
		agile.requireX("dijit/form/CheckBox");
		return dijit.form.CheckBox.prototype;
	}
	,initDefaultMetadata:function(){
		 this.metadata("parameters.value","");
		 this.metadata("parameters.checked",false);
		 this.metadata("style.width","16px");		
		 this.metadata("style.height","16px");
	}
//	 ,constructor: function(){	
//		 this.metadata("parameters.value","");
//		 this.metadata("parameters.checked",false);
//		 this.metadata("style.width",16);		
//		 this.metadata("style.height",16);			
//	 }	
	,init:function(){
		this.delegate.watch("checked",lang.hitch(this,function(name,old,value){
			if(!this._notWatchChecked){
				this.onValueChange(value);
			}
			this._notWatchChecked = false;
		}));
		
		//reset the check status so that the radio button can be selected next time
		aspect.after(this,"onDeselected",lang.hitch(this,function(){
			this._notWatchChecked = true;
			this.delegate.set("checked",false);
		}));
		
		this.delegate.set("checked",this.metadata("parameters.checked"));
	}
	,onValueChange:function(newValue){
		topic.publish("agile.widget.changed",this.category,"checked",newValue);					
		this.metadata("parameters.checked",newValue);	
	}
[/@]